import request from '@/utils/request.ts'
const baseUrl = '/wallpaper'

/**
 * 获取轮播图
 * @param {Object} params
 */
export function apiGetBanner(params) {
  return request({
    url: baseUrl + '/banner/list',
    method: 'get',
    data: params,
  })
}

/**
 * 获取每日推荐
 */
export function apiGetDayRandom() {
  return request({
    url: baseUrl + '/wall/randomWall',
  })
}

/**
 * 获取公告列表
 */
export function apiGetNotice(data = {}) {
  return request({
    url: baseUrl + '/wallNewsList',
    method: 'get',
    data,
  })
}

/**
 * 获取公告详情
 */
export function apiNoticeDetail(id) {
  return request({
    url: baseUrl + `/wallNewsDetail/${id}`,
    method: 'get',
  })
}

/**
 * 获取壁纸详情
 */
export function apiDetailWall(id) {
  return request({
    url: baseUrl + `/wall/${id}`,
    method: 'get',
  })
}

/**
 * 获取验证码
 *
 */
export function apiGetCodeImg() {
  return request({
    url: '/captchaImage',
    headers: {
      isToken: false,
    },
    method: 'get',
    timeout: 20000,
  })
}

export function apiGetUserInfo() {
  return request({
    url: baseUrl + '/personalInfo',
    method: 'get',
  })
}

export function apiGetHistoryList(data = {}) {
  return request({
    url: '/userWallList',
    data,
  })
}

export function apiSearchData(data = {}) {
  return request({
    url: '/searchWall',
    data,
  })
}
// 发布
export function apiCreatePosting() {
  return request({
    url: baseUrl + '/posting/list',
    method: 'post',
  })
}

/**
 * 获取专辑排行榜
 * @param {Object} data
 */
export function apiGetAlbumRank(data = {}) {
  return request({
    url: baseUrl + '/albumRank/list',
    method: 'get',
    data,
  })
}

// 获取专辑详情
export function apiGetAlbumDetail(id) {
  return request({
    url: baseUrl + `/album/${id}`,
    method: 'get',
  })
}

/**
 * 获取壁纸排行榜
 * @param {Object} data
 */
export function apiGetWallRank(data = {}) {
  return request({
    url: baseUrl + '/wallRank/list',
    method: 'get',
    data,
  })
}
// 获取壁纸详情
export function apiGetWallDetail(id) {
  return request({
    url: baseUrl + `/wall/${id}`,
    method: 'get',
  })
}

// 获取分类列表
export function apiGetClassify(params) {
  return request({
    url: baseUrl + '/classify/list',
    method: 'get',
    data: params,
  })
}

// 获取壁纸列表
export function apiGetWallList(params) {
  return request({
    url: baseUrl + '/wall/list',
    method: 'get',
    data: params,
  })
}

// 获取专辑列表
export function apiGetAlbumList(data = {}) {
  return request({
    url: baseUrl + '/album/list',
    method: 'get',
    data,
  })
}

// 评分壁纸
export function apiGetSetupScore(data = {}) {
  return request({
    url: baseUrl + `/wall/score`,
    method: 'put',
    data,
  })
}

//用户获取个人发布列表
export function apiGetUserPostingList(data = {}) {
  return request({
    url: baseUrl + '/posting/userPosts',
    method: 'get',
    data,
  })
}

//取消发布
export function apiCancelPosting(data = {}) {
  return request({
    url: baseUrl + `/posting/user`,
    method: 'put',
    data,
  })
}

//获取发布详情
export function apiGetPostingDetail(data = {}) {
  return request({
    url: baseUrl + `/posting/postDetail`,
    method: 'get',
    data,
  })
}

//判断是否收藏
export function apiIsCollect(data = {}) {
  return request({
    url: baseUrl + `/collection/isCollection`,
    method: 'get',
    data,
  })
}
